import request, {buildQueryString} from "@/utils/request";
export  interface UserSearchForm {
    username?: string;
    phone?: string;
    deptId?: number;
    roleCodes?: string[];
    createTimeRange?: string[];
    updateTimeRange?: string[];
    dataStatus?: number;
    page?: number;
    pageSize?: number;
}
export function getUserList(data: UserSearchForm){
    return request.get(`/user${buildQueryString(data)}`)
}
export interface UserForm {
    username: string;
    password: string;
    nickname: string;
    deptId?: number;
    avatar: string;
    phone: string;
    dataStatus?: number;
    roleIds?: number[];
}
export function insertUser(data: UserForm) {
    return request.post('/user',data)
}
export interface UpdateUserForm extends UserForm{
    id: number;
}
export function updateUser(data: UpdateUserForm) {
    return request.put('/user',data)
}
export function getUserById(id: number) {
    return request.get(`/user/getUserById/${id}`)
}
export function deleteUser(id: number) {
    return request.delete(`/user/${id}`)
}
export function changePassword(data: {password: string;newPassword: string}) {
    return request.put('/user/changePassword',data)
}
